home *** CD-ROM | disk | FTP | other *** search
/ CD World 1998 January / CD World - Ocak 1998.iso / misc / dbase55 / disk7 / cbtsamp.pak / ANIMALS.WFM < prev    next >
Text File  |  1996-01-05  |  9KB  |  359 lines

  1. *******************************************************************************
  2. *  PROGRAM:      Animals.wfm
  3. *
  4. *  WRITTEN BY:   Borland Samples Group
  5. *
  6. *  DATE:         1/94
  7. *
  8. *  UPDATED:      5/95
  9. *
  10. *  REVISION:     $Revision:   2.83  $
  11. *
  12. *  VERSION:      Visual dBASE
  13. *
  14. *  DESCRIPTION:  This program shows the ability of Visual dBASE to traverse a
  15. *                table and display its contents in a form.  The form created in
  16. *                this program has entryfields displaying names and habitats of
  17. *                different animals, pushbuttons that allow you to move to the
  18. *                next/previous animal or exit, and an image displaying the
  19. *                current animal.
  20. *
  21. *  PARAMETERS:   None
  22. *
  23. *  CALLS:        Buttons.cc      (Custom Controls file)
  24. *                Animals.qbe     (View of table -- you can also use Animsql.qbe,
  25. *                                                  which uses local SQL to
  26. *                                                  accomplish the same tasks)
  27. *
  28. *  USAGE:        DO Animals.wfm
  29. *
  30. ********************************************************************************
  31. create session
  32. set talk off
  33. set ldCheck off
  34.  
  35. ** END HEADER -- do not remove this line*
  36. * Generated on 05/23/95
  37. *
  38. parameter bModal
  39. local f
  40. f = new ANIMALSFORM()
  41. if (bModal)
  42.    f.mdi = .F. && ensure not MDI
  43.    f.ReadModal()
  44. else
  45.    f.Open()
  46. endif
  47. CLASS ANIMALSFORM OF FORM
  48.    Set Procedure to &_dbwinhome.samples\Buttons.cc Additive
  49.    this.OnOpen = CLASS::ONOPEN
  50.    this.OnClose = CLASS::ONCLOSE
  51.    this.View = "ANIMALS.QBE"
  52.    this.Text = "Animals"
  53.    this.Top = 0
  54.    this.Height = 13.1758
  55.    this.Width = 63.666
  56.    this.TopMost = .F.
  57.    this.PageNo = 1
  58.    this.OnNavigate = CLASS::ONNAVIGATE
  59.    this.Maximize = .F.
  60.    this.Minimize = .F.
  61.    this.Left = 20
  62.    this.OnSize = CLASS::ONSIZE
  63.    this.ColorNormal = "BtnFace"
  64.  
  65.    DEFINE RECTANGLE INFORECTANGLE OF THIS;
  66.        PROPERTY;
  67.          Text "",;
  68.          Height 13.0195,;
  69.          Top 0.0977,;
  70.          Width 63.1357,;
  71.          PageNo 1,;
  72.          Left 0.1973,;
  73.          MousePointer 3,;
  74.          Border .T.,;
  75.          FontSize 6.5,;
  76.          BorderStyle 1,;
  77.          ColorNormal "BtnFace"
  78.  
  79.    DEFINE TEXT TITLETEXT OF THIS;
  80.        PROPERTY;
  81.          FontName "Times New Roman",;
  82.          FontBold .F.,;
  83.          Text "Animals of the World",;
  84.          Top 0.5,;
  85.          Height 1.5586,;
  86.          Width 61.666,;
  87.          PageNo 1,;
  88.          Left 1,;
  89.          Border .F.,;
  90.          FontSize 22,;
  91.          ColorNormal "R/BtnFace",;
  92.          Alignment 4
  93.  
  94.    DEFINE TEXT NAMETEXT OF THIS;
  95.        PROPERTY;
  96.          FontName "Arial",;
  97.          FontBold .F.,;
  98.          FontItalic .T.,;
  99.          Text "Name",;
  100.          Top 3.2344,;
  101.          Height 1.3535,;
  102.          Width 7,;
  103.          PageNo 1,;
  104.          Left 2,;
  105.          Border .F.,;
  106.          FontSize 10,;
  107.          ColorNormal "B/BtnFace",;
  108.          Alignment 5
  109.  
  110.    DEFINE ENTRYFIELD NAMEENTRY OF THIS;
  111.        PROPERTY;
  112.          FontName "Arial",;
  113.          ColorHighLight "N/GB+",;
  114.          Top 3.2344,;
  115.          Height 1.3535,;
  116.          Width 16.502,;
  117.          Enabled .F.,;
  118.          PageNo 1,;
  119.          DataLink "NAME",;
  120.          Left 10.8311,;
  121.          Border .T.,;
  122.          FontSize 10,;
  123.          ColorNormal "N/GB+"
  124.  
  125.    DEFINE TEXT SIZETEXT OF THIS;
  126.        PROPERTY;
  127.          FontName "Arial",;
  128.          FontBold .F.,;
  129.          FontItalic .T.,;
  130.          Text "Size",;
  131.          Top 4.7637,;
  132.          Height 1.2949,;
  133.          Width 7,;
  134.          PageNo 1,;
  135.          Left 2,;
  136.          Border .F.,;
  137.          FontSize 10,;
  138.          ColorNormal "B/BtnFace",;
  139.          Alignment 5
  140.  
  141.    DEFINE ENTRYFIELD SIZEENTRY OF THIS;
  142.        PROPERTY;
  143.          FontName "Arial",;
  144.          ColorHighLight "N/GB+",;
  145.          Top 4.7637,;
  146.          Height 1.2949,;
  147.          Width 5.002,;
  148.          Enabled .F.,;
  149.          PageNo 1,;
  150.          DataLink "SIZE",;
  151.          Left 10.8311,;
  152.          Border .T.,;
  153.          FontSize 10,;
  154.          ColorNormal "N/GB+"
  155.  
  156.    DEFINE TEXT WEIGHTTEXT OF THIS;
  157.        PROPERTY;
  158.          FontName "Arial",;
  159.          FontBold .F.,;
  160.          FontItalic .T.,;
  161.          Text "Weight",;
  162.          Top 6.2344,;
  163.          Height 1.3535,;
  164.          Width 7,;
  165.          PageNo 1,;
  166.          Left 2,;
  167.          Border .F.,;
  168.          FontSize 10,;
  169.          ColorNormal "B/BtnFace",;
  170.          Alignment 5
  171.  
  172.    DEFINE ENTRYFIELD WEIGHTENTRY OF THIS;
  173.        PROPERTY;
  174.          FontName "Arial",;
  175.          ColorHighLight "N/GB+",;
  176.          Top 6.2344,;
  177.          Height 1.3535,;
  178.          Width 5.002,;
  179.          Enabled .F.,;
  180.          PageNo 1,;
  181.          DataLink "WEIGHT",;
  182.          Left 10.8311,;
  183.          Border .T.,;
  184.          FontSize 10,;
  185.          ColorNormal "N/GB+"
  186.  
  187.    DEFINE TEXT AREATEXT OF THIS;
  188.        PROPERTY;
  189.          FontName "Arial",;
  190.          FontBold .F.,;
  191.          FontItalic .T.,;
  192.          Text "Area",;
  193.          Top 7.7637,;
  194.          Height 1.2949,;
  195.          Width 7,;
  196.          PageNo 1,;
  197.          Left 2,;
  198.          Border .F.,;
  199.          FontSize 10,;
  200.          ColorNormal "B/BtnFace",;
  201.          Alignment 5
  202.  
  203.    DEFINE ENTRYFIELD AREAENTRY OF THIS;
  204.        PROPERTY;
  205.          FontName "Arial",;
  206.          ColorHighLight "N/GB+",;
  207.          Top 7.7637,;
  208.          Height 1.2949,;
  209.          Width 24.335,;
  210.          Enabled .F.,;
  211.          PageNo 1,;
  212.          DataLink "AREA",;
  213.          Left 10.8311,;
  214.          Border .T.,;
  215.          FontSize 10,;
  216.          ColorNormal "N/GB+"
  217.  
  218.    DEFINE RECTANGLE IMAGERECT OF THIS;
  219.        PROPERTY;
  220.          Text "",;
  221.          Height 9.5488,;
  222.          Top 3.0977,;
  223.          Width 26.166,;
  224.          PageNo 1,;
  225.          Left 36.5,;
  226.          Border .T.,;
  227.          BorderStyle 2,;
  228.          ColorNormal "N/BtnFace"
  229.  
  230.    DEFINE IMAGE ANIMALIMAGE OF THIS;
  231.        PROPERTY;
  232.          Top 3.1475,;
  233.          Height 9.4404,;
  234.          Width 25.6689,;
  235.          PageNo 1,;
  236.          Left 36.6641,;
  237.          DataSource "BINARY BMP"
  238.  
  239.    DEFINE PREVBUTTON PREVANIMALBUTTON OF THIS;
  240.        PROPERTY;
  241.          Group .T.,;
  242.          Top 9.5,;
  243.          Height 1.5586,;
  244.          Width 14.168,;
  245.          OnClick CLASS::PREV_ONCLICK,;
  246.          Left 2.832
  247.  
  248.    DEFINE NEXTBUTTON NEXTANIMALBUTTON OF THIS;
  249.        PROPERTY;
  250.          Group .T.,;
  251.          Top 9.5,;
  252.          Height 1.5586,;
  253.          Width 14.168,;
  254.          OnClick CLASS::NEXT_ONCLICK,;
  255.          Left 20.665
  256.  
  257.    DEFINE CLOSEBUTTON CLOSEANIMALSBUTTON OF THIS;
  258.        PROPERTY;
  259.          Group .T.,;
  260.          Default .T.,;
  261.          Top 11.2988,;
  262.          Height 1.5244,;
  263.          Width 14.166,;
  264.          Left 11.5
  265.  
  266.    DEFINE SAMPLEINFOBUTTON ANIMALSINFOBUTTON OF THIS;
  267.        PROPERTY;
  268.          Group .T.,;
  269.          Text "",;
  270.          Top 0.2998,;
  271.          Height 1.1699,;
  272.          Width 3.5,;
  273.          Left 59.5
  274.  
  275.    PROCEDURE OnOpen
  276.    ****************************************************************************
  277.  
  278.    *** Do calculations in another workarea so form is not affected
  279.    use animals again in select() order name alias temp
  280.    go bottom in temp
  281.    form.lastRec = recno("temp")
  282.    go top in temp
  283.    form.firstRec = recno("temp")
  284.    use in temp
  285.    ***
  286.  
  287.    form.animalsInfoButton.sampleName = "Animals.wfm"
  288.    form.closeAnimalsButton.SetFocus()
  289.  
  290.  
  291.    ****************************************************************************
  292.  
  293.    PROCEDURE NEXT_OnClick
  294.  
  295.    * Go to next record.
  296.    ****************************************************************************
  297.  
  298.    NEXTBUTTON::OnClick()
  299.    if recno() = form.lastRec        && If on last record, move to prevButton
  300.       form.prevAnimalButton.setfocus()
  301.    endif
  302.  
  303.  
  304.    ****************************************************************************
  305.  
  306.    PROCEDURE PREV_OnClick
  307.  
  308.    * Go to previous record.
  309.    ****************************************************************************
  310.  
  311.    PREVBUTTON::OnClick()
  312.    if recno() = form.firstRec       && If on first record, move to nextButton
  313.       form.nextAnimalButton.setfocus()
  314.    endif
  315.  
  316.  
  317.    ****************************************************************************
  318.  
  319.    PROCEDURE OnNavigate
  320.  
  321.    * If animal has size > 10, change background color of the size entryfield
  322.    * to red.
  323.    ****************************************************************************
  324.  
  325.    if size > 10
  326.       form.sizeEntry.colornormal = "gb+/r"
  327.       form.statusmessage = "Animal has size > 10."
  328.    else
  329.       form.sizeEntry.colornormal = "n/gb+"
  330.       form.statusmessage = ""
  331.    endif
  332.  
  333.  
  334.    ****************************************************************************
  335.  
  336.    PROCEDURE OnSize ( SizeType, NewWidth, NewHeight )
  337.  
  338.    * Resize main form rectangle as the form is resized.
  339.    ****************************************************************************
  340.  
  341.    form.infoRectangle.height = max(NewHeight -.2, 0)
  342.    form.infoRectangle.width = max(NewWidth - .5, 0)
  343.  
  344.  
  345.    ****************************************************************************
  346.  
  347.    PROCEDURE OnClose
  348.  
  349.    * Clean up.
  350.    ****************************************************************************
  351.  
  352.    close procedure &_dbwinhome.samples\Buttons.cc
  353.  
  354.  
  355. ENDCLASS
  356.  
  357.  
  358.  
  359.